//--

		self.crab:AddRelationship("npc_headcrab D_NU 999")
		self.crab:AddRelationship("npc_headcrab_fast D_NU 999")
		self.crab:AddRelationship("npc_headcrab_black D_NU 999")

antlion = self.Entity

//--
	function ENT:SearchForFood()
	self.nofood = true

		//PrintMessage(HUD_PRINTTALK,self.name.." is searching for food.")

		--find corpses in x radius and eat
		local sphents = ents.FindInSphere(self.crab:GetPos(),32)
		for i, thent in ipairs(sphents) do
			if thent:GetClass() == "prop_ragdoll" then
			if thent:GetModel() == "models/headcrabclassic.mdl" or thent:GetModel() == "models/headcrab.mdl" or thent:GetModel() == "models/headcrabblack.mdl" then
				if self.hunger > 30 then
					thent:Remove()
					self.hunger = self.hunger - 100
				end
			end
			end
		end
		
		--find w'melons in x radius and goto (if we don't already have a valid w'mn, or our w'melon is too far away)
		if ValidEntity(self.watermelon) == false or self.crab:GetPos():Distance(self.watermelon:GetPos()) > 32 then
			local sphentseat = ents.FindInSphere(self.crab:GetPos(),self.searchradius)
			local closest = 1024
			for i, thenteat in pairs(sphentseat) do
			//for i, thenteat in ipairs(sphentseat) do
				if not thenteat:IsNPC() then
				if thenteat:GetModel() == "models/headcrabclassic.mdl" or thenteat:GetModel() == "models/headcrab.mdl" or thenteat:GetModel() == "models/headcrabblack.mdl" && thenteat:GetPos():Distance(self.crab:GetPos()) < closest && self.hunger > self.hungry then
					self.crab:SetLastPosition(thenteat:GetPos()+Vector(0,0,0))
					self.watermelon = theenteat
					self.crab:SetSchedule(71)
					self.nofood = false
					closest = thenteat:GetPos():Distance(self.crab:GetPos())
					break
				//elseif thenteat:GetClass() != "colonies_watermelon" || thenteat:GetPos():Distance(self.crab:GetPos()) >= closest || self.hunger <= self.hungry then
				end
				end


			end

			if self.nofood then
				
				self.crab:AddRelationship("npc_headcrab D_HT 999")
				self.crab:AddRelationship("npc_headcrab_fast D_HT 999")
				self.crab:AddRelationship("npc_headcrab_black D_HT 999")
				
				PrintMessage(HUD_PRINTTALK,self.name.." couldn't find food. Now hostile.")
			local sphentseat = ents.FindInSphere(self.crab:GetPos(),self.searchradius)
				local closest = 1024
				for i, thenteat in pairs(sphentseat) do
					if not thenteat:GetModel() == "models/headcrabclassic.mdl" and not thenteat:GetModel() == "models/headcrab.mdl" and not thenteat:GetModel() == "models/headcrabblack.mdl" then
						local journey = math.random(1,self.wanderchance)
						if journey <= 2 then self.Entity:Wander() end
					end
				end
					
			end
		end

	end

function ENT:Fight()
	Foundtarget = false

	self.crab:SetSchedule(5) //Not sure if this actually does anything.

	//Note: this function scans the surrounding area for enemies.
		//PrintMessage(HUD_PRINTTALK,self.name.." is fighting.")

		local sphentseat = ents.FindInSphere(self.crab:GetPos(),self.searchradius)
		for i, thenteat in pairs(sphentseat) do
		//local en
		//for i, #sphentseat do
				//PrintMessage(HUD_PRINTTALK,"Data: "..i.." ... "..thenteat)
				//if 
			if thenteat:GetPos():Distance(self.crab:GetPos()) < self.searchradius then
				if thenteat:IsPlayer() or thenteat:IsNPC() then
					//PrintMessage(HUD_PRINTTALK,"Data: "..i)
					//PrintMessage(HUD_PRINTTALK,self.name..": What is it?: "..thenteat:GetClass())

					if thenteat == self.crab.Currenttarget then
						self.crab.CombatMode = true
						Foundtarget = true
						self.Entity:AttackTarget()
					end
					
					if thenteat:GetClass() == self.crab.Currenttargettype and thenteat ~= self.crab.Currenttarget then
						self.crab.alterntarget = thenteat
						//PrintMessage(HUD_PRINTTALK,self.name..": Found an alternative target")
					end

					if thenteat:GetClass() == "npc_antlion" or thenteat:GetClass() == "npc_antlion*" then
					//if thenteat:GetClass() == "colonies_antlion" or thenteat:GetClass() == "colonies_antlion*" then
						//if thenteat:IsValid() and thenteat ~= self.crab and Foundtarget and thenteat.Currenttarget == nil then
						if thenteat:IsValid() and thenteat ~= self.crab and Foundtarget and not thenteat.Combatmode then
							if thenteat:GetPos():Distance(self.crab.Currenttarget:GetPos()) < self.searchradius then
								thenteat.CombatMode = true
								thenteat.Currenttarget = self.crab.Currenttarget
								thenteat.Currenttargettype = self.crab.Currenttargettype
								//PrintMessage(HUD_PRINTTALK,self.name..": Come and help me!")
								//self.Entity:Fight()
							end
						end
					end

				end
			end
				
		end

		if not Foundtarget then
			if self.crab.alterntarget ~= nil then
			self.crab.Currenttarget = self.crab.alterntarget
			//PrintMessage(HUD_PRINTTALK,self.name..": Switching targets")
			else
			self.Entity:TargetLost()
			//PrintMessage(HUD_PRINTTALK,self.name..": Target cannot be seen")
			end
		end

end

//---
		if not self.crab.CombatMode then
		
			self.crab:AddRelationship("npc_headcrab D_NU 999")
			self.crab:AddRelationship("npc_headcrab_fast D_NU 999")
			self.crab:AddRelationship("npc_headcrab_black D_NU 999")
		end